﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ModelLayer;
using DBLayer;
/// <summary>
/// Controls plans and seats 
/// </summary>
namespace CtrLayer
{
    public class PlaneCtr
    {
        //Variables initialization
        private PlaneDB planeDB;
        private SeatDB seatDB;

        //constructor
        public PlaneCtr()
        {
            seatDB = new SeatDB();
            planeDB = new PlaneDB();
        }
        #region Plane
        //Creates a Plane object and calls DB to insert it into database.
        public int InsertPlane(Plane _plane)
        {
            return planeDB.InsertPlane(_plane);
        }
        //Calls DB to search database efter a Plane object by planeNo
        public Plane FindPlaneByPlaneNo(string _planeNo)
        {
            return planeDB.FindPlaneByPlaneNo(_planeNo);
        }
        public List<Plane>SelectAllPlanes()
        {
            return planeDB.SelectAll();
        }
        //update Plane by obj
        public int UpdatePlane(Plane _plane)
        {
            return planeDB.UpdatePlane(_plane);
        }
        //remove Plane by obj
        public int RemovePlane(Plane _plane)
        {
            return planeDB.RemovePlane(_plane);
        }
        #endregion
        #region Seat
        //Creates a Seat object and calls DB to insert it into database.
        public int InsertSeat(Seat _seat)
        {
            return seatDB.InsertSeat(_seat);
        }
        //remove Seat by obj
        public int RemoveSeat(Seat _seat)
        {
            return seatDB.RemoveSeat(_seat);
        }
        //Calls DB to search database efter a Seat object by seatNo
        public Seat FindSeatBySeatNoAndPlaneNo(string _seatNo, string _planeNo)
        {
            return seatDB.FindSeatBySeatNoAndPlaneNo(_seatNo, _planeNo);
        }
        //Find all seats on a plane
        public List<Seat> FindAllSeatsOnPlane(Plane _plane)
        {
            return seatDB.FindSeatsByPlane(_plane);
        }
        //Select all seats
        public List<Seat> SelectAllSeats()
        {
            return seatDB.SelectAll();
        }
        //find reserved seats
        public List<Seat> FindBookedSeats(FlightInstance _flightInstance)
        {
            return seatDB.FindBookedSeats(_flightInstance);
        }
        #endregion


    }
}
